package com.litchi.tutor.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.litchi.tutor.common.base.ResponseVO;
import com.litchi.tutor.common.entity.User;
import com.litchi.tutor.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author XuRuiPeng
 * @date 2021/11/4 15:56
 */
@RequestMapping("/dashboard")
@RestController
@Api("管理员接口")
public class DashBoardController {

    @Autowired
    UserService userService;

    @ApiOperation("设置staff")
    @RequestMapping(value = "/staff{id}/{staff}", method = RequestMethod.PUT)
    public ResponseVO updateStaff(@PathVariable String id, @PathVariable Boolean staff) {
        User user = userService.getOne(new QueryWrapper<User>().eq("id", id));
        user.setStaff(staff);
        userService.updateById(user);
        return ResponseVO.ok(null);
    }
}
